#CSV文件写入
import csv
# with open('dataa.csv', mode='w', encoding='utf-8', newline='') as csvfile:
#     w = csv.writer(csvfile)
#     w.writerow(['hello', 'shiwo', 123, 'hhah'])
#     w.writerow(['', 3333, 'correct','qq'])
#     w.writerows([['wqw',2323,'ceshui','data'],[1212]])

# with open('little.csv',mode='w',encoding='utf8',newline='') as csvfile:
#     w = csv.writer(csvfile)
#     w.writerow(['用户名','密码'])
#     for i in range(1,101):
#         t = 'tester'+str(i)
#         w.writerow([t,'123456'])

#文件读取

# with open('little.csv',encoding='utf-8') as csvfile:
#     r = csv.reader(csvfile)
#     for i in r:
#         print(i)
    # print(r)

#字典写入
# with open('little.csv',mode='w',encoding='utf8',newline='') as csvfile:
#     header = ['用户名','密码']
#     r = csv.DictWriter(csvfile,fieldnames=header)
#     r.writeheader()
#     for i  in range (1,101):
#         r.writerow({'用户名':'test'+str(i),'密码':'123456'})

#用户登录
import csv
test_data = []
with open('little.csv', encoding='utf8') as csvfile:
    r = csv.reader(csvfile)
    for line in r:
        # print(line)
        test_data.append(line)
print(test_data)
#删除list中第一行数据
test_data.pop(0)

import pytest
import requests
@pytest.mark.parametrize('username,passwd',test_data)
def test_login(username, passwd):
    url = 'http://49.233.108.117:3000/signin'
    post_data = {
        "name": username,
        "pass": passwd,
        "_csrf": None
    }
    r = requests.post(url, data=post_data)
    assert r.status_code ==200
    print('开始登陆', username, passwd)